//
//  NetWork.m
//  PhoenixNews
//
//  Created by dllo on 15/11/11.
//  Copyright © 2015年 Dior_3g. All rights reserved.
//

#import "NetWork.h"

@implementation NetWork

+ (void)netWork:(id)view {
    
    //      检测网络情况
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    //      开始检测
    [manager startMonitoring];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        if (status == 1) {

            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示信息" message:@"当前网络为移动网络" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            [alert addAction:ok];
            [view presentViewController:alert animated:YES completion:^{
            }];
           
        } else if (status == 2) {

            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示信息" message:@"当前网络为Wifi" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            [alert addAction:ok];
            [view presentViewController:alert animated:YES completion:^{
                
            }];
          
        } else {

            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示信息" message:@"当前无网络" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            [alert addAction:ok];
            [view presentViewController:alert animated:YES completion:^{
                
            }];
         
        }

    }];

    [manager stopMonitoring];
}
@end
